/*
Filename:    sctp_one_to_many_connection.cpp
Author:      Erik Öjebo
Date:        2009-01-10
Description: Result object for the SctpOneToMany receive methods.
             Holds information about:
             - message size (which is an error code if negative)
             - the association id that sent the message
             - the address of the sender
             - if the received message was a notification or not
             - error number, if an error occurred.
*/

#ifndef SCTP_RECEIVE_RESULT_H_
#define SCTP_RECEIVE_RESULT_H_

#include "address.h"
#include <netinet/sctp.h>

class SctpReceiveResult
{
public:
    SctpReceiveResult()
        : messageSize(0), associationId(0), errorNumber(0) {};

    // Getters and setters for the properties:

    // Size in bytes of the received message. Negative size indicates error.
    ssize_t getMessageSize() const { return messageSize; }
    void setMessageSize(ssize_t size) { messageSize = size; }

    // Id of the association on which the message was received
    sctp_assoc_t getAssociationId() const { return associationId; }
    void setAssociationId(sctp_assoc_t id) { associationId = id; }

    // The address of the sender
    const Address& getPeerAddress() const { return peerAddress; }
    void setPeerAddress(Address address) { peerAddress = address; }

    // Indicates if the received data was a notification of an ordinary message
    bool wasNotification() const { return wasMessageNotification; }
    void setWasNotification(bool value) { wasMessageNotification = value; }

    // Error number (errno) if an error occurred, zero otherwise
    int getErrorNumber() const { return errorNumber; }
    void setErrorNumber(int number) { errorNumber = number; }

private:
    ssize_t messageSize;
    sctp_assoc_t associationId;
    Address peerAddress;
    bool wasMessageNotification;
    int errorNumber;
};

#endif /* SCTP_RECEIVE_RESULT_H_ */
